<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AfterAddress extends Model
{
    protected $table = "c_after_addresses";

    public function add($address_id,$after_id)
    {
        $this->where([['after_id','=',$after_id]])->delete();
        $addres = (new OrderAddress())->where([['id','=',$address_id]])->first();
        $this->after_id = $after_id;
        $this->name = $addres->name;
        $this->phone = $addres->phone;
        $this->detail = $addres->detail;
        $this->province_id = $addres->province_id;
        $this->city_id = $addres->city_id;
        $this->district_id = $addres->district_id;
        return $this->save();
    }


    public function del($after_id)
    {
        return $this::where([['after_id', '=', $after_id]])->delete();
    }
}
